<?php
require('config.php');

        $goods_id=$_REQUEST['goods_id'];
		$sql="select ".$oto."_goods_appraises.*,".$oto."_users.userName from `".$oto."_goods_appraises`,`".$oto."_users` where ".$oto."_users.userId=".$oto."_goods_appraises.userId and `goodsId`='".$goods_id."' and isShow='1' order by ".$oto."_goods_appraises.`createTime` DESC";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$person_info[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(isset($person_info))
		{
			$sum=0;
			for($i=0;$i<count($person_info);$i++)
			{
				$orderId=$person_info[$i]['orderId'];
				$sql="select * from `".$oto."_share` where `goodsId`='".$goods_id."' and orderId='{$orderId}' and isShow='1' order by `shareTime` DESC";
				$result=$db->query($sql);
				while($row=$result->fetch_assoc()){
					$img_info[$i]=$row;//将取得的所有数据赋值给person_info数组
				}
				if(isset($img_info[$i]))
				{
					$person_info[$i]['isShowImg']=$img_info[$i]['isShow'];
					$person_info[$i]['shareImg1']=$img_info[$i]['shareImg1'];
					$person_info[$i]['shareImg2']=$img_info[$i]['shareImg2'];
					$person_info[$i]['shareImg3']=$img_info[$i]['shareImg3'];
					$person_info[$i]['shareImg4']=$img_info[$i]['shareImg4'];
				}
				else
				{
					$person_info[$i]['isShowImg']="0";
					$person_info[$i]['shareImg1']="";
					$person_info[$i]['shareImg2']="";
					$person_info[$i]['shareImg3']="";
					$person_info[$i]['shareImg4']="";
				}
				$sum+=$person_info[$i]['goodsScore'];
			}
			$lin=(($sum/count($person_info))/5)*100;
			$person_info[0]['persen']=floatval($lin);
			echo json_encode($person_info);
		}
		else echo '[]';
?>